
import java.util.Scanner;

public class fibArrays2 {
	static Scanner sc = new Scanner(System.in);

	public static void main(String[] args) 
	{
		int min =1;		//min for input variable
		int max =1000;  //max for input variable
		
		int n1,n2;
		
		double phi = ( (double) 1 + Math.sqrt(5))/2;
		int [] fibArray = new int[26];	
		double q = 0;
		fibArray[0]=0;

		n1=getNumber(min,max);		//get and validate first int.
		n2=getNumber(min,max);		//get and validate second int.
		
		for ( int i=1, n3 = 0 ; i< fibArray.length ; i++, n3=n2+n1, n1=n2, n2=n3 )
		{
			System.out.print(i + " :  ");
			fibArray[i]= n3;
			int e = fibArray[i-1];
			
			if (0<e )
			{
				q = (double) (fibArray[i]) / (double) e;				
				double diff = Math.abs(q-phi);
				System.out.format("%d + %d = %d : q= %.13f : diff= %.13f\n", fibArray[ i-2], fibArray[i-1], fibArray[i], q, diff);    // 3+5=8 : q= 1.625
			}
			else
			{
				System.out.format("fib = %d\n", n3);
			}
		} 
	}

	
	
	private static int getNumber(int min, int max)
	{
		boolean valid;
		int x=0;
		do{
			valid=true;
			System.out.println("Enter an integer between "+ min +" and " + max+ " :");
			x=sc.nextInt();
			if( x>min && x<max)
			{
				System.out.println("Thanks!");
				valid=true;
			} 
			else 
			{
				System.out.println("HEY! That's not right! Try again.");
				valid=false;
			}
		}while (!valid);
		return x;
	}
}
